package com.hspedu.newData.dmsxl.数组.双指针;

import org.junit.Test;

/**
 * @Author: yh
 * @description: 
 * @CreateTime: 2025-04-22 
 * @Version: 1.0
 */

public class LC26删除数组中的重复项 {

    public int removeDuplicates(int[] nums) {
        int slow = 0;
        int fast = 0;
        while(fast < nums.length){
            if (nums[fast]!= nums[slow]){
                nums[++slow] = nums[fast];
            }
            fast++;
        }
        return ++slow;
    }

    @Test
    public void test(){
        int[] nums = new int[]{1,1,2};
        int[] nums1 = new int[]{0,0,1,1,1,2,2,3,3,4};
        int i = removeDuplicates(nums);
        int j = removeDuplicates(nums1);
        System.out.println("==============");
    }
}
